package cn.didi.feidi.androidorder.assembly;

import android.app.Dialog;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.didi.feidi.androidorder.R;
import cn.didi.feidi.androidorder.databinding.DialogDeleteGoodsBinding;

/**
 * Created by jinxiong on 2017/8/22.
 */

public class DeleteGoodsFragmentDialog extends BaseDialogFragment {

    DialogDeleteGoodsBinding binding;
    View.OnClickListener mOnClickListener; // 左边操作回调
    private String title = "删除所选商品？";//标题
    private String leftMessage = "狠心删除"; //左边文字
    private String rightMessage = "再想想";//右边文字


    @Override
    protected Dialog newDialog() {
        Dialog dialog = new Dialog(getActivity(), R.style.style_dialog);
        binding = DataBindingUtil.inflate(getActivity().getLayoutInflater(), R.layout.dialog_delete_goods,
                (ViewGroup) getActivity().getWindow().getDecorView(), false);

        dialog.setContentView(binding.getRoot());
        return dialog;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        addListener();
        return super.onCreateView(inflater, container, savedInstanceState);
    }


    @Override
    protected void addListener() {

        binding.itemShoppingCarThinkTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

        binding.itemShoppingCarDeleteGoodsTv.setOnClickListener(mOnClickListener);

    }

    @Override
    protected void initView() {

        binding.itemShoppingCarTitleTv.setText(title);
        binding.itemShoppingCarDeleteGoodsTv.setText(leftMessage);
        binding.itemShoppingCarThinkTv.setText(rightMessage);
    }

    public DeleteGoodsFragmentDialog setTitle(String title) {
        this.title = title;
        return this;
    }

    public DeleteGoodsFragmentDialog setLeftMessage(String leftMessage) {
        this.leftMessage = leftMessage;
        return this;
    }

    public DeleteGoodsFragmentDialog setRightMessage(String rightMessage) {
        this.rightMessage = rightMessage;
        return this;
    }

    public DeleteGoodsFragmentDialog setOnClickListener(View.OnClickListener onClickListener) {
        mOnClickListener = onClickListener;
        return this;
    }


}
